<?php

/**
 * Puntaje form base class.
 *
 * @method Puntaje getObject() Returns the current form's model object
 *
 * @package    preuvideo
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BasePuntajeForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'         => new sfWidgetFormInputHidden(),
      'colegio_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Colegio'), 'add_empty' => false)),
      'agno'       => new sfWidgetFormInputText(),
      'n'          => new sfWidgetFormInputText(),
      'promedio'   => new sfWidgetFormInputText(),
      'min'        => new sfWidgetFormInputText(),
      'max'        => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'         => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'colegio_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Colegio'))),
      'agno'       => new sfValidatorInteger(),
      'n'          => new sfValidatorInteger(),
      'promedio'   => new sfValidatorPass(),
      'min'        => new sfValidatorPass(),
      'max'        => new sfValidatorPass(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Puntaje', 'column' => array('colegio_id')))
    );

    $this->widgetSchema->setNameFormat('puntaje[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Puntaje';
  }

}
